package models;

import java.util.ArrayList;
import java.util.List;

public class Courbe {
	//liste de points
	
	private List<Double> _tabPoints;
	
	public Courbe() {
		_tabPoints = new ArrayList<Double>();
	}
	
	public Courbe(int n, Double val) {
		_tabPoints = new ArrayList<Double>();
		
		for (int i = 0; i < _tabPoints.size(); i++ ){
			_tabPoints.set(i, val);
		}
	}
	
	public double getPoint(int index) {
		return _tabPoints.get(index);
	}

	public void setPoint(int index, double val) {
		_tabPoints.set(index, val);
	}
	
	public int getSize() {
		return _tabPoints.size();
	}
	
	public Courbe add(Double n) {
		Courbe courbeResult = new Courbe(_tabPoints.size(), 0.0);
		for (int i = 0; i < _tabPoints.size(); i++) {
			courbeResult.setPoint(i, _tabPoints.get(i)+n);
		}
		
		return courbeResult;
	}
	
	public Courbe add(Courbe courbe) {
		Courbe courbeResult = new Courbe(_tabPoints.size(), 0.0);
		for (int i = 0; i < _tabPoints.size(); i++) {
			courbeResult.setPoint(i, _tabPoints.get(i)+courbe.getPoint(i));
		}
		
		return courbeResult;
	}
	
	public Courbe multiple(Double n) {
		Courbe courbeResult = new Courbe(_tabPoints.size(), 0.0);
		for (int i = 0; i < _tabPoints.size(); i++) {
			courbeResult.setPoint(i, _tabPoints.get(i)*n);
		}
		
		return courbeResult;
	}
	
	public Courbe multiple(Courbe courbe) {
		Courbe courbeResult = new Courbe(_tabPoints.size(), 0.0);
		for (int i = 0; i < _tabPoints.size(); i++) {
			courbeResult.setPoint(i, _tabPoints.get(i)*courbe.getPoint(i));
		}
		
		return courbeResult;
	}
}
